package model;

import java.io.Serializable;

import javax.persistence.*;
import model.Member;

/**
 * The persistent class for the vote database table.
 * 
 */
@Entity
@NamedQuery(name="Vote.findAll", query="SELECT v FROM Vote v")
public class Vote implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private int idVote;
	//bi-directional one-to-one association to Citizen
		@OneToOne(mappedBy = "vote")
		private Citizen citizen;
		
	//bi-directional one-to-one association to Party
	@OneToOne(mappedBy="vote")
	private Party party1;

	//bi-directional many-to-one association to Election
	@ManyToOne
	@JoinColumn(name="idElection")
	private Election election;

	//bi-directional many-to-one association to Party
	@ManyToOne
	@JoinColumn(name="idParty")
	private Party party2;

	//bi-directional many-to-one association to Member
	@ManyToOne
	@JoinColumn(name="preference1", referencedColumnName = "idMember")
	private int preference1;
	@JoinColumn(name="preference2", referencedColumnName = "idMember")
	private int preference2;
	@JoinColumn(name="preference3", referencedColumnName = "idMember")
	private int preference3;
	@PrimaryKeyJoinColumn
	private Member member;
	
	
	public Vote(Citizen c, Party p, Member[] pref) {
		this.citizen = c;
		this.party1 = p;
		this.preference1 = pref[0].getIdMember();
		this.preference2 = pref[1].getIdMember();
		this.preference3 = pref[2].getIdMember();
	}
	
	public Vote(){
		
	}
	

	public int getIdVote() {
		return this.idVote;
	}

	public void setIdVote(int idVote) {
		this.idVote = idVote;
	}

	public Party getParty1() {
		return this.party1;
	}

	public void setParty1(Party party1) {
		this.party1 = party1;
	}

	public Election getElection() {
		return this.election;
	}

	public void setElection(Election election) {
		this.election = election;
	}

	public Party getParty2() {
		return this.party2;
	}

	public void setParty2(Party party2) {
		this.party2 = party2;
	}

	public Member getMember() {
		return this.member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	public int getPreference1() {
		return preference1;
	}

	public void setPreference1(int preference1) {
		this.preference1 = preference1;
	}

	public int getPreference2() {
		return preference2;
	}

	public void setPreference2(int preference2) {
		this.preference2 = preference2;
	}

	public int getPreference3() {
		return preference3;
	}

	public void setPreference3(int preference3) {
		this.preference3 = preference3;
	}

	public Citizen getCitizen() {
		return citizen;
	}

	public void setCitizen(Citizen citizen) {
		this.citizen = citizen;
	}
	

}